package com.hs.javassist;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;

/**
 * @Author: hs
 * @Description:
 * @Date: Create in 17:43 2019/9/2
 */
public class SprintAssist {
    public static void main(String[] args) throws Exception{
        CtClass ctClass = ClassPool.getDefault().get("com.hs.javassist.MyA");
        CtConstructor declaredConstructor = ctClass.getDeclaredConstructor(null);
        declaredConstructor.setBody("{ System.out.println(\"构造函数。。\"); }");
        Object o = ctClass.toClass().newInstance();
        System.out.println(o);
    }
}
